View Javadoc

1   // jq_SynchThreadQueue.java, created Mon Apr  9  1:52:50 2001 by joewhaley
2   // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package joeq.Scheduler;
5   
6   import joeq.Runtime.Unsafe;
7   import jwutil.util.Assert;
8   
9   /*
10   * @author  John Whaley <jwhaley@alum.mit.edu>
11   * @version $Id: jq_SynchThreadQueue.java 1941 2004-09-30 03:37:06Z joewhaley $
12   */
13  public class jq_SynchThreadQueue extends jq_ThreadQueue {
14  
15      //public synchronized boolean isEmpty() { return super.isEmpty(); }
16      public void enqueue(jq_Thread t) {
17          Assert._assert(Unsafe.getThreadBlock().isScheduler);
18          synchronized (this) {
19              super.enqueue(t);
20          }
21      }
22      public synchronized void enqueueFront(jq_Thread t) {
23          Assert._assert(Unsafe.getThreadBlock().isScheduler);
24          synchronized (this) {
25              super.enqueueFront(t);
26          }
27      }
28      public synchronized jq_Thread dequeue() {
29          Assert._assert(Unsafe.getThreadBlock().isScheduler);
30          synchronized (this) {
31              return super.dequeue();
32          }
33      }
34      public synchronized boolean remove(jq_Thread t2) {
35          Assert._assert(Unsafe.getThreadBlock().isScheduler);
36          synchronized (this) {
37              return super.remove(t2);
38          }
39      }
40  
41  }